using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[Serializable]
public class TimedSimpleKillEvent : KillEvent, ITimedEvent
{
	public int neededKills;

	public float neededTime;

	public bool disableIfAchieved = true;

	public bool achieved;

	public bool onlinekill = true;

	public bool IfEvent(KillInfo newKill, List<KillInfo> KillsIList)
	{
		if (onlinekill != newKill.onlineKill)
		{
			return false;
		}
		if (!achieved)
		{
			int num = 1;
			foreach (KillInfo KillsI in KillsIList)
			{
				if (newKill.time - KillsI.time <= neededTime)
				{
					num++;
					if (num == neededKills)
					{
						return true;
					}
				}
			}
		}
		return false;
	}

	public IEnumerator DisableForTime()
	{
		AddToAchidedList();
		if (disableIfAchieved)
		{
			achieved = true;
		}
		yield return new WaitForSeconds(neededTime);
		Reset();
	}

	public void AddToAchidedList()
	{
		GameplayEventsManager.instance.allTimedEvents.Add(this);
	}

	public void Reset()
	{
		achieved = false;
	}
}
